package com.koala.learn.streamlearn;

import com.google.common.collect.Lists;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description TODO
 * @Date 2022/5/20 2:11
 * @Created by koala
 */

public class Start {

    @Test
    public void test20() {
        ArrayList<Person> peoples = Lists.newArrayList();


        // todo
    }

    /**
     * 流重复
     */
    @Test
    public void test12() {
        ArrayList<Person> peoples = Lists.newArrayList(new Person(), new Person(), new Person(), new Person("tom", 1), new Person("koaoa", 1));
        peoples.stream().collect(Collectors.toMap(Person::getAge, v -> Lists.newArrayList(v), (List<Person> newValueList, List<Person> oldValueList) -> {
            oldValueList.addAll(newValueList);
            return oldValueList;
        }));
    }

    /**
     *
     */
    @Test
    public void test42() {
        List<String> sentences = Arrays.asList("hello Tom", "I am Lixiang");
        String strs = sentences.stream().flatMap(v -> Arrays.stream(v.split(" "))).collect(Collectors.joining(","));
        System.out.println(strs);
    }
}
